<?php
/**
 * The template for displaying all pages.
 *
 * This is the template that displays all pages by default.
 * Please note that this is the WordPress construct of pages
 * and that other 'pages' on your WordPress site will use a
 * different template.
 *
 * @package WordPress
 * @subpackage Twenty_Eleven
 * @since Twenty Eleven 1.0
 */

get_header(); ?>
		<div id="primary">
			<div class="container" id="marca" role="main">
				<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
					<div class="fr"><?php get_template_part( 'filtro-origem'); ?></div>
					<h1 class="entry-title fl">FORNECEDORES</h1>
					<br class="clear">
					<div class="entry-content lstfornecedores">
					<?php
					$filtro = array();
					if($_GET["o"]){
						$origem = $_GET["o"];
						$filtro = array(
							'key'       => 'origem',
							'value'     => $origem,
							'compare'   => '==',
						);
					}
					$args = array(
						'authors'      => '',
						'child_of'     => $post ->ID,
						'date_format'  => get_option('date_format'),
						'depth'        => 0,
						'echo'         => 1,
						'exclude'      => '',
						'include'      => '',
						'link_after'   => '',
						'link_before'  => '',
						'post_type'    => 'page',
						'post_status'  => 'publish',
						'show_date'    => '',
						'sort_column'  => 'menu_order, post_title',
						'title_li'     => __('Pages'), 
						'walker'       => '',
						'order'        => 'ASC',
						'orderby'      => 'title',
						'nopaging'     => true,
						'meta_query'   => array(
							array(
								'key'       => 'imagem',
								'value'     => '',
								'compare'   => '!=',
							),
							$filtro,
						),
					);
					query_posts($args);
					while ( have_posts() ) : the_post();
						/*<header class="entry-header"> <h1 class="entry-title"><?php the_title(); ?></h1> </header>.entry-header*/
						$array = get_post_custom_values('imagem'); 
						$imagem = $array[0];
						?>
						<div class="fl">
							<a href="<?=the_permalink();?>"><img src="<?=get_bloginfo('wpurl');?>/wp-content/files_mf/<?=$imagem;?>" /></a>
						</div>
					<?php
					endwhile;
					?>
					</div><!-- .entry-content -->
				</article><!-- #post-<?php the_ID(); ?> -->
				<div class="clear"></div>
			</div><!-- #content -->
		</div><!-- #primary -->
<?php get_sidebar('page'); ?>
<?php get_footer(); ?>